package com.duqc.designpattern.observer;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @ClassName WechatListener
 * @Description 观察者模式（创建事件监听类-公众号监听）
 * @Author duqc
 * @Date 2021/5/11
 **/
@Async
@Slf4j
@Component
public class WechatListener implements ApplicationListener<PayEvent> {

    @Override
    public void onApplicationEvent(PayEvent payEvent) {
        String topic = payEvent.getTopic();
        Map<String, String> map = payEvent.getMap();
        log.info("订阅主题是:" + topic + ";发送公众号消息:" + map.get("msg"));
    }
}
